import util.DbUtil
DbUtil.prepare()
def sql = DbUtil.sql
def insertAthlete = '''insert into t_athlete(firstname, lastname) values(?,?)'''
def datas = [
		['a', 'a'],
		['b', 'b'],
		['c', 'c'],
		['d', 'd'],
		['e', 'e'],
		['f', 'f'],
		['g', 'g'],
		['h', 'h']
	]
datas.each {
	sql.execute insertAthlete, it
}

def rows = sql.rows('select * from t_athlete')
println rows.size()

// 分页, 每页 5 条数据, 第一页从 1 开始, 第二页当然就从 6 开始 ... 
def page1 = sql.rows('select * from t_athlete', 1, 5)
def page2 = sql.rows('select * from t_athlete', 6, 5)
// 第三页只有一条数据
def page3 = sql.rows('select * from t_athlete', 11, 5)
// 空的话, 会返回 null
def page4 = sql.rows('select * from t_athlete', 16, 5)

println ' page '.center(25, '-')
println page1
println page2
println page3
println page4

sql.close()
